package com.zhang.designmode.wangzheng_design_mode.prototype;

/**
 * @Author: zxz
 * @DateTime: 2022/3/7 14:40
 * @Description: TODO
 */
public class Person implements Cloneable {
    private String name;
    private Integer age;
    private House house;

    public House getHouse() {
        return house;
    }

    public Person setHouse(House house) {
        this.house = house;
        return this;
    }

    public String getName() {
        return name;
    }

    public Person setName(String name) {
        this.name = name;
        return this;
    }

    public Integer getAge() {
        return age;
    }

    public Person setAge(Integer age) {
        this.age = age;
        return this;
    }


    @Override
    public Person clone() {
        try {

            // TODO: copy mutable state here, so the clone can't change the internals of the original
            Person clone = (Person) super.clone();
            House house = (House) this.house.clone();
            clone.house = house;
            return clone;
        } catch (CloneNotSupportedException e) {
            throw new AssertionError();
        }
    }
}
